home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / misc / DevHandler103.lha / DevHandler.doc < prev    next >
Text File  |  1995-05-08  |  18KB  |  481 lines

  1.  
  2.                               The DEV Handler 1.03
  3.  
  4.                        Console, AUX and Raw Disk Handler
  5.  
  6.                  (c) 1995 Martin Mares, MJSoft System Software
  7.  
  8. ================================================================================
  9.  
  10.  
  11. Preface
  12. =======
  13.  
  14.    The DEV Handler package and its documentation are Copyright (c) Martin Mares,
  15. MJSoft System Software, Prague, Czech Republic.
  16.  
  17.    This  archive  can  be  freely  redistributed as long as all of its files are
  18. included   in   their   original   form  without  any  additions,  deletions  or
  19. modifications  (excluding addition of other README-style files and icons) and no
  20. more  than a nominal fee is charged for its distribution.  All copyright notices
  21. in  the  programs and accompanying documentation files must remain intact.  It's
  22. especially  forbidden  to add various '.displayme' files and BBS advertisements.
  23. This style of distribution is generally known as FREEWARE.
  24.  
  25.    Special  permission  is  given  to  Fred Fish to include this software on his
  26. "Fish  Disks".
  27.  
  28.    This  software  is  provided  "AS  IS"  without  warranty of any kind, either
  29. expressed  or  implied.   The author is not responsible for any damage caused by
  30. it.
  31.  
  32.  
  33. Introduction
  34. ============
  35.  
  36.    - UNIX has named consoles.  Amiga doesn't.  They're very useful when you need
  37. to  say which console is someone logged on (a good example are the who and write
  38. utilities).
  39.  
  40.    - UNIX has special files representing devices.  Amiga doesn't.   They're very
  41. useful  for  tar-like  programs  to  access the devices directly without knowing
  42. about  Amiga  device  concept  (by the way, the Amiga access is much more better
  43. than  the  one  in UNIX, because it's completely asynchronous, but sometimes you
  44. prefer simplicity even with lower efficiency).
  45.  
  46.    - UNIX consoles and special files have multiuser protection.  Amiga doesn't.
  47.  
  48.    - There was no console and AUX handler satisfying all my requirements.
  49.  
  50.    This handler tries to be a solution to all of these problems. It creates a
  51. disk-like volume named Devices containing devices of the following kinds:
  52.  
  53.     (1)  Consoles. Each console can have its own screen. Also borderless windows
  54.      and similar specialities are supported. You can open the screen and set
  55.      its parameters (including colors) without using any other tool. The
  56.      keyboard command set is slightly extended. All standard packets are
  57.      supported.
  58.  
  59.     (2)  AUX devices. Something like console, but connected to a serial-like
  60.      device instead of a window. When the carrier is lost, EOF is sent to
  61.      all pending read requests and a break signal is sent to processes which
  62.      use the console.
  63.  
  64.     (3)  Softlinks. You can install a soft link to any file. Icons may be
  65.      handled this way. You can also make all your volumes to DEV:
  66.  
  67.     (4)  Raw access to devices. Both stream and block devices are supported.
  68.  
  69.  
  70. Installation and configuration
  71. ==============================
  72.  
  73.    Copy DEVHandler to your handler directory (usually L:) and create a mount
  74. entry for it (in DEVS:Mountlist or DEVS:DOSDrivers/DEV, according to system
  75. version you use):
  76.  
  77. DEV:    Handler = L:DEVHandler            /* Correct this path */
  78.     StackSize = 2048
  79.     Priority = 5
  80.     GlobVec = -1
  81.     Startup = S:DEVHandler.config        /* Or any name you want */
  82.  
  83.    Also copy the Force command somewhere you like to have it in.
  84.  
  85.    After these steps, it would be good to create the configuration file
  86. mentioned in the mount entry. This file is a normal text file with comments
  87. introduced by semicolons (everything from the first semicolon to the end of the
  88. line is ignored). It consists of definition blocks - one for each device.
  89.  
  90.    Possible parameters are listed here: (many of them may be omitted, the
  91. required ones are marked with [R])
  92.  
  93. (1) Screen definition:
  94.  
  95.    SCREEN <name>    [R]    Name of public screen (must be the first line)
  96.    WIDTH <n>            Screen width in pixels (default=as Workbench)
  97.    HEIGHT <n>            Screen height in pixels (default=as Workbench)
  98.    DEPTH <n>            Number of bitplanes (default=as Workbench)
  99.    TITLE <title>        Screen title
  100.    DISPLAYID <mode>        Display mode for this screen = MonitorType
  101.                 (0=default, $21000=PAL, $11000=NTSC, $31000=VGA,
  102.                 $41000=A2024, $61000=EURO72, $71000=EURO36,
  103.                 $81000=SUPER72, $91000=DBLNTSC, $A1000=DBLPAL)
  104.                 + $8000 for HIRES / $8020 for SUPERHIRES
  105.                 + $0004 for interlace
  106.                 + $0080 for halfbrite mode
  107.                 (for other idents see graphics/modeid.[ih])
  108.    BEHIND <b>            If active (set to 1), the screen is opened in
  109.                 behind the others.
  110.    AUTOSCROLL <b>        If active, the screen is autoscrolled if it's
  111.                 larger than the visible display.
  112.    COLOR0 <n>            RGB value for color #0 ($000 to $FFF)
  113.    COLOR1 <n>            RGB value for color #1 ($000 to $FFF)
  114.    COLOR2 <n>            RGB value for color #2 ($000 to $FFF)
  115.    COLOR3 <n>            RGB value for color #3 ($000 to $FFF)
  116.  
  117. (2) Console definition:
  118.  
  119.    CONSOLE <name>    [R]    Name of console device (must be the first line)
  120.    LEFT <n>            Left edge of the window (default=0)
  121.    TOP <n>            Top edge of the window (default=0)
  122.    WIDTH <n>            Width of the window (default=full screen)
  123.    HEIGHT <n>            Height of the window (default=full screen)
  124.    TITLE <s>            Window title (don't set for backdrop windows)
  125.    ACTIVE <b>            If active, the window is activated when opened
  126.    BORDERLESS <b>        If active, the window has no border
  127.    PUBSCREEN <name>        Open the window on the specified public screen
  128.    CLIP <b>            If active, console clipping is allowed
  129.    BUFSIZE <n>            Size of input buffer (default=512 bytes)
  130.    UNIXMODE <b>            If active, it behaves as on UNIX systems - if
  131.                 you type anything, the output is not suppressed.
  132.                 The only way to stop it is using of CTRL-S
  133.                 (XOFF), continue by CTRL-Q (XON).
  134.    HISTSIZE <n>            Size of history buffer (default=1024 bytes).
  135.                 If zero, no history is available.
  136.    RMBTRAP <b>            If active, the right mouse button is ignored
  137.                 and doesn't stop console output.
  138.  
  139. (3) AUX definition:
  140.  
  141.    AUX <name>        [R]    Name of AUX device (must be the first line)
  142.    DEVICE <name>    [R]    Name of device to be used for I/O
  143.    UNIT <n>            Device unit to be used (default=0)
  144.    FLAGS <n>            Device flags to be used (default=0)
  145.    BUFLEN <n>            Device buffer size (default set by the device)
  146.    BAUD <n>            Baud rate (default=9600)
  147.    BITS <n>            Number of data bits (default=8)
  148.    STOPBITS <n>            Number of stop bits (default=1)
  149.    SERFLAGS <n>            Flags for the serial device:
  150.                 $00=no parity, $01=even, $03=odd
  151.                 + $04 for RS-232 7-wire protocol
  152.                 + $10 for high-speed mode
  153.                 + $20 for shared access
  154.                 + $80 for XON/XOFF mode (default=$20)
  155.    CHECKCD <n>            Carrier will be tested. In case it's been lost,
  156.                 all read requests are returned with EOF, all
  157.                 writes are rejected with write error and breaks
  158.                 are sent to all users. (default=0)
  159.    TERM <n>            Terminal type: 0=Amiga, 1=Amiga with CR+LF,
  160.                 2=something which should work with VT100
  161.                 (default=0)
  162.    BUFSIZE <n>            Size of input buffer (default=512 bytes)
  163.    UNIXMODE <b>            If active, it behaves as on UNIX systems - if
  164.                 you type anything, the output is not suppressed.
  165.                 The only way to stop it is using of CTRL-S
  166.                 (XOFF), continue by CTRL-Q (XON).
  167.    HISTSIZE <n>            Size of history buffer (default=1024 bytes).
  168.                 If zero, no history is available.
  169.  
  170. (4) Softlink definition:
  171.  
  172.    LINK <name>        [R]    Name of the link (must be the first line)
  173.    DEST <s>        [R]    Link destination
  174.  
  175. (5) Raw device definition:
  176.  
  177.    RAWDEVICE <name>    [R]    Name of the device (must be the first line)
  178.    DEVICE <s>        [R]    System device to be used
  179.    UNIT <n>            Device unit (default=0)
  180.    FLAGS <n>            Device flags (default=0)
  181.    BUFMEMTYPE <n>        Memory type for I/O buffers (1=any, 3=chip,
  182.                 5=fast ; default=1)
  183.    BLOCKSIZE <n>        Size of one block (not specified or zero for
  184.                 stream devices)
  185.    BUFFER <n>            Buffer size in blocks (or bytes if stream dev)
  186.                 Stream devices have buffered only writes (or
  187.                 nothing if no buffer is specified). Block
  188.                 devices must have some buffer.
  189.    SIZE <n>            Device size in bytes (0=stream, -1=infinite,
  190.                 -2=autodetect via ReadGeometry command)
  191.    EXCLUSIVE <b>        If active, only one open at a time is allowed
  192.    UPDATE <b>            If active, the UPDATE command is sent after last
  193.                 write request. Use for trackdisk-like devices.
  194.    MOTOR <b>            If active, turn off drive motor after the device
  195.                 is closed. Use for trackdisk-like devices.
  196.    CLEAR <b>            If active, all device buffers are flushed (via
  197.                 the CLEAR command) when a read/write error is
  198.                 detected.
  199.    READCMD <n>            Device command number used for reading.
  200.                 (default=2=CMD_READ)
  201.    WRITECMD <n>            Device command number used for writing.
  202.                 (default=3=CMD_WRITE)
  203.  
  204. (6) Global parameters (can be used for any device)
  205.  
  206.    PERMANENT <b>        If active, the device is always in opened state.
  207.                 If not set, the device is activated when it's
  208.                 opened and deactivated when closed. (If you
  209.                 specify a permanent screen, it will be still
  210.                 open. If it is not permanent (default), it will
  211.                 be opened as soon as some console will try to
  212.                 use it.)
  213.    FROM <name>            Copy all settings from given device defined
  214.                 before this one. The device must be of the same
  215.                 type as the current one.
  216.  
  217.    Warning #1: Strings are not enclosed in quotes, even if they contain spaces.
  218.  
  219.    Warning #2: DEVHandler is not foolproof. If you specify incorrect values of
  220. some options, it might crash.
  221.  
  222.    If a fatal error in the config file is found, a small window is opened and
  223. the error is announced. After this, the handler exits normally.
  224.  
  225.    For some examples, see the example config file (DevHandler.config) in this
  226. archive.
  227.  
  228.  
  229. Differences
  230. ===========
  231.  
  232.    There are some differences between DEVHandler consoles and the standard CBM
  233. CON handler:
  234.  
  235.       - Large writes are split automatically allowing to stop any write between
  236.     lines.
  237.  
  238.       - Control sequences are buffered, so if you send a control sequence in two
  239.     consecutive writes, the console won't insert anything between them (in
  240.     standard CON, you can type a character inside it!).
  241.  
  242.       - If you use the RCOMMAND-V (paste) combination in raw mode, the control
  243.     sequence for pasting will be sent before the actually pasted data. It
  244.     makes the raw mode completely transparent (all data received from
  245.     console.device are sent to you, but some of them are also interpreted -
  246.     such as breaks and the paste).
  247.  
  248.       - CTRL-S and CTRL-Q act as normal XOFF and XON characters. (Used to stop
  249.     the output anywhere and to continue afterwards.)
  250.  
  251.       - UNIX mode may be activated. In this case, any line being edited doesn't
  252.     stop display output. Some people like it.
  253.  
  254.       - Buffer sizes and other useful constants may be set.
  255.  
  256.       - You can force EOF on the console using the Force command (see below).
  257.         You can use this feature if there's someone logged on your system and
  258.         you want to disconnect him. This command requires the ss.library
  259.         version 5.0 or higher (can be found on the AmiNet).
  260.  
  261.       - You can put the currently edited line to history buffer without sending
  262.     it to your program by pressing CTRL-B.
  263.  
  264.       - It's possible to delete not only words delimited by spaces, but also
  265.         words consisting only from letters, digits and underlines by CTRL-R.
  266.  
  267.       - All characters except $00 and $9B can be stored to the line. In the raw
  268.     mode, no restrictions on character codes apply.
  269.  
  270.       - You can Examine() the console. In this case, the datestamp returned
  271.     tells you when has then user typed the last character. (Useful for
  272.     WHO-like utilities.)
  273.  
  274.  
  275. Multiuser protection
  276. ====================
  277.  
  278.    If the multiuser.library is found, full multi-user protection mechanisms
  279. are applied:
  280.  
  281.    - There are no restrictions on screens
  282.  
  283.    - Console and AUX devices normally belong to root and are openable by anyone.
  284. In case first user opens the console, its owner is changed to that user. If it's
  285. released, the owner is set back to root.
  286.  
  287.    - Links are readable by anyone.
  288.  
  289.    - Raw devices act like normal files.
  290.  
  291.    Each device has usual protection bits. They may be altered by the current
  292. owner and are set back to the defaults when the device is closed. If root
  293. modifies the protections, they are set as the defaults.
  294.  
  295.    Access rights are cached on file open, therefore if you pass a filehandle to
  296. anyone, the access rights you had on open are used.
  297.  
  298.    If you are root or you're in the root group, you can do anything the owner
  299. of the file can. Some packets are available only to root.
  300.  
  301.    Default protection bits:
  302.  
  303.     CONSOLE/AUX    owner rw, group w, other w
  304.     LINK        all r
  305.     RAWDISK        owner rwd (The d bit is set because the copy command
  306.             duplicates protection bits and would generate undele-
  307.             table files.)
  308.  
  309. Supported packets
  310. -----------------
  311.  
  312.    This section lists all DOS packets handled by the DEVHandler. Each of these
  313. packets is described, its arguments and access right restrictions are listed.
  314.  
  315. (1) Standard packets for all devices:
  316.  
  317.    DIE() -> success                             [ONLY ROOT]
  318.    Shut down the handler. Rejected if you are not root or if there still remain
  319.    some locks.
  320.  
  321.    CURRENT_VOLUME() -> BPTR volume
  322.    Get current (and the only) volume.
  323.  
  324.    LOCATE_OBJECT(BPTR lock,BSTR name,LONG mode) -> BPTR lock
  325.    Create a lock.
  326.  
  327.    FREE_LOCK(BPTR lock) -> success
  328.    Free a lock.
  329.  
  330.    COPY_DIR(BPTR lock) -> BPTR lock
  331.    Duplicate a lock.
  332.  
  333.    SET_PROTECT(zero, BPTR lock, BSTR name, LONG mask) -> success    [ONLY OWNER]
  334.    Set protection bits. If you are root, the protections are set as a default.
  335.  
  336.    EXAMINE_OBJECT(BPTR lock, BPTR fib) -> success
  337.    EXAMINE_NEXT(BPTR lock, BPTR fib) -> success
  338.    Standard directory examination mechanism.
  339.  
  340.    DISK_INFO(BPTR infodata) -> success
  341.    Get information about current volume.
  342.  
  343.    INFO(BPTR lock,BPTR infodata) -> success
  344.    Get information about volume associated with given lock. DEVHandler gives
  345.    the same result for all locks.
  346.  
  347.    PARENT(BPTR lock) -> BPTR lock
  348.    Get parent of given lock.
  349.  
  350.    SAME_LOCK(BPTR lock1, BPTR lock2) -> result
  351.    Compare two locks (see dos/SameLock)
  352.  
  353.    READ(LONG arg1,APTR buffer,LONG size) -> size           [READ RIGHTS]
  354.    Read data from console/aux/raw device.
  355.  
  356.    WRITE(LONG arg1,APTR buffer,LONG size) -> size          [WRITE RIGHTS]
  357.    Write data to console/aux/raw device.
  358.  
  359.    FINDUPDATE(BPTR lock,BPTR fh,BPTR name) -> success      [READ OR WRITE RIGHTS]
  360.    FINDINPUT(BPTR lock,BPTR fh,BPTR name) -> success      [READ OR WRITE RIGHTS]
  361.    FINDOUTPUT(BPTR lock,BPTR fh,BPTR name) -> success      [READ OR WRITE RIGHTS]
  362.    Open a file. In case it's a console, the file handle is redirected to the
  363.    corresponding internal console handler.
  364.  
  365.    END(LONG arg1) -> success
  366.    Close a file.
  367.  
  368.    SEEK(LONG arg1,LONG offset,LONG mode) -> oldpos
  369.    Seek a file.
  370.  
  371.    IS_FILESYSTEM() -> TRUE
  372.  
  373.    SET_OWNER(zero, BPTR lock, BSTR name, LONG ugid) -> success        [ONLY OWNER]
  374.    Set owner of a file.
  375.  
  376.    READ_LINK(BPTR lock,STRPTR name,APTR buffer,LONG size) -> length
  377.    Read contents of a soft link.
  378.  
  379. (2) Standard packets for the console/AUX subhandlers. (If you want to use them,
  380. you must open the console and extract handler port from the file handle.)
  381.  
  382.    WAIT_CHAR(LONG ticks) -> ischar                   [READ RIGHTS]
  383.    Wait for character is available (returns after specified time with FALSE or
  384.    with TRUE as soon as some character is available).
  385.  
  386.    DISK_INFO(BPTR infodata) -> success                   [READ RIGHTS]
  387.    Return information about the console:
  388.  
  389.     infodata->id_DiskType = 'CON'<<8 if console, 'RAW'<<8 if con in RAW mode
  390.                 'CONA' if AUX, 'RAWA' if AUX in RAW mode
  391.     infodata->id_VolumeNode = Window (0 if AUX)
  392.     infodata->id_InUse = device IORequest
  393.  
  394.    READ(LONG arg1,APTR buffer,LONG size) -> size           [READ RIGHTS]
  395.    Read data from the console.
  396.  
  397.    WRITE(LONG arg1,APTR buffer,LONG size) -> size          [WRITE RIGHTS]
  398.    Write data to the console.
  399.  
  400.    SCREEN_MODE(LONG mode)                      [WRITE RIGHTS]
  401.    Switch the console to RAW mode or back (mode=TRUE if RAW, FALSE if not).
  402.  
  403.    CHANGE_SIGNAL(???, APTR task) -> APTR task              [WRITE RIGHTS]
  404.    Set task to send breaks to.
  405.  
  406.    FINDINPUT,FINDOUTPUT(BPTR lock,BPTR fh,BSTR name) -> success  [R or W RIGHTS]
  407.    Create a new filehandle for this console. (Used to duplicate a file handle,
  408.    for example by NewShell.)
  409.  
  410.    END(LONG arg1) -> success
  411.    Close a filehandle.
  412.  
  413.    STACK(LONG arg1,APTR buffer,LONG size) -> size     [READ AND WRITE RIGHTS]
  414.    Insert something into console buffer. It will be read before all other input.
  415.  
  416.    QUEUE(LONG arg1,APTR buffer,LONG size) -> size     [READ AND WRITE RIGHTS]
  417.    Insert something into console buffer. It will be read after all other input.
  418.  
  419. (3) Non-standard packets for the console:
  420.  
  421.    INHIBIT(BOOL flag) -> success                    [ONLY OWNER]
  422.    If flag=TRUE, the console will be blocked until the same packet with flag set
  423.    to FALSE. While in inhibited state, the device used by AUX is not touched and
  424.    no IORequests are active.
  425.  
  426.    FORCE() -> success                            [ONLY OWNER]
  427.    Force EOF on this console. All read requests are returned with EOF, all write
  428.    packets are rejected with error. Break is sent as if CTRL-C and CTRL-D was
  429.    pressed.
  430.  
  431.    CHANGE_TERM(LONG termtype) -> success                [ONLY OWNER]
  432.    Set terminal type to specified one (see DEVHandler.i: DHTERM_#?).
  433.  
  434.  
  435. Planned enhancements
  436. ====================
  437.  
  438.    - New packet ABORT(LONG arg1) which would try to abort any operation in
  439. progress. (It's sometimes needed to break an already sent console read packet
  440. on program exit.)
  441.  
  442.    - More keyboard commands for the console (e.g., program priority control)
  443.  
  444.    - File name completion in the console
  445.  
  446.    - Console scrollback buffer
  447.  
  448.    - Some packet allowing dynamic creation of devices. (A telnet-daemon could
  449. use this feature.)
  450.  
  451.    - EXAMINE_FH, FH_FROM_LOCK and some other useful packets.
  452.  
  453.    - Setting of default protection bits and default owner in config file.
  454.  
  455.  
  456. History
  457. =======
  458.  
  459. 1.0 (17.1.95)  - Original release (after almost six months of beta testing)
  460.  
  461. 1.01 (12.2.95) - Example DevHandler.config file included in the archive
  462.                  (it was mentioned in original doc, but it was missing).
  463.  
  464.            - Two enforcer hits in lock handling functions fixed.
  465.  
  466. 1.02 (14.2.95) - Small bug in DupLock packet (introduced in 1.01) removed.
  467.  
  468.            - The Startup field in Device structure set to 0 (reset back
  469.          on exit), because some silly programs (including MUI
  470.          VolumeList gadget) incorrectly assumed it to contain
  471.          FileSysStartupMsg.
  472.  
  473. 1.03 (15.2.95) - Fixed break handling.
  474.  
  475.  
  476. Final words
  477. ===========
  478.  
  479.    Send bug reports, flames and suggestions to <mj@k332.feld.cvut.cz>.
  480.  
  481.